package com.smartmedical.patient.sickcricle.controller;

import com.smartmedical.common.core.domain.HealthR;
import com.smartmedical.common.security.utils.SecurityUtils;
import com.smartmedical.patient.sickcricle.domain.SickCircle;
import com.smartmedical.patient.sickcricle.domain.SickCircleCommentCount;
import com.smartmedical.patient.sickcricle.domain.SickCircleCount;
import com.smartmedical.patient.sickcricle.service.SickCollectionService;
import com.smartmedical.patient.sickcricle.vo.SickCircleCommentVo;
import com.smartmedical.patient.sickcricle.vo.SickCirclePublishVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

@RestController
@RequestMapping("/user/sickCircle/verify/v1")
public class SickCollectionController {

    @Autowired
    private SickCollectionService sickCollectionService;

    /**
     * 病友圈收藏
     */
    @PostMapping("/addUserSickCollection")
    public HealthR<Integer> addUserSickCollection(@RequestBody SickCircleCount sickCircleCount) {

        return sickCollectionService.addUserSickCollection(sickCircleCount);


    }

    /**
     * 取消病友圈收藏
     */
    @DeleteMapping("/cancelSickCollection")
    public HealthR<Integer> cancelSickCollection(@RequestBody SickCircleCount sickCircleCount) {

        return sickCollectionService.cancelSickCollection(sickCircleCount);

    }


    /**
     * 病友圈发表评论
     */
    @PostMapping("/publishComment")
    public HealthR publishComment(@RequestParam Integer sickCircleId, @RequestParam String content) {

        return sickCollectionService.publishComment(sickCircleId, content);

    }

    /**
     * 采纳病友圈评论
     */
    @PutMapping("/adoptionProposal")
    public HealthR adoptionProposal(
            @RequestHeader(value = "userId", required = false) Integer userId,
            @RequestHeader(value = "Sessionid", required = false) String sessionId,
            @RequestParam Integer sickCircleId,
            @RequestParam Integer commentId) {

        return sickCollectionService.adoptionProposal(sickCircleId, commentId);

    }

    /**
     * 查看我的病友圈发帖列表
     */
    @GetMapping("/findMySickCircleList")
    public HealthR<List<SickCirclePublishVo>> findMySickCircleList(
            @RequestHeader(value = "userId", required = false) Integer userId,
            @RequestHeader(value = "Sessionid", required = false) String sessionId,
            @RequestParam Integer page,
            @RequestParam Integer count) {

        return sickCollectionService.findMySickCircleList(page, count);

    }

    /**
     * 查询我的病友圈帖子的评论列表
     */
    @GetMapping("/findMySickCircleCommentList")
    public HealthR<List<SickCircleCommentVo>> findMySickCircleCommentList(
            @RequestHeader(value = "userId", required = false) Integer userId,
            @RequestHeader(value = "Sessionid", required = false) String sessionId,
            @RequestParam Integer sickCircleId,
            @RequestParam Integer page,
            @RequestParam Integer count) {
        return sickCollectionService.findSickCircleCommentList(sickCircleId, page, count);

    }

    /**
     * 发布病友圈
     */
    @PostMapping("/publishSickCircle")
    public HealthR publishSickCircle(@RequestHeader(value = "userId", required = false) Integer userId,
                                     @RequestHeader(value = "Sessionid", required = false) String sessionId,
                                     @RequestBody SickCircle sickCircle) {
        return sickCollectionService.publishSickCircle(sickCircle);

    }

    /**
     * 赞同观点
     */
    @PutMapping("/expressOpinion")
    public HealthR expressOpinion(@RequestParam Integer commentId, @RequestParam Integer opinion) {

      return  sickCollectionService.expressOpinion(commentId, opinion);

    }


    /**
     * 上传用户病友圈相关图片
     */
    @PostMapping("/uploadSickCirclePicture")
    public HealthR uploadSickCirclePicture(@RequestHeader(value = "userId", required = false) Integer userId,
                                           @RequestHeader(value = "Sessionid", required = false) String sessionId,
                                           @RequestParam Integer sickCircleId,
                                           @RequestParam("file") MultipartFile picture) {
        HealthR healthR = sickCollectionService.uploadSickCirclePicture(sickCircleId, picture);

        return healthR;


    }







}























